package guoanmaker.operator.business.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.model.OperatorAdvertisingPush;
import guoanmaker.operator.business.service.OperatorAdvertisingPushServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;

/**
 * @ClassName: OperatorAdvertisingPushController
 * @author: lsy 
 * @date 2018/3/12  
 */

@RestController
@RequestMapping(ApiController.OPERATOR_ADVERTISING_PUSH)
public class OperatorAdvertisingPushController {
	@Resource
	private OperatorAdvertisingPushServiceInterface advertisingPushServiceInterface;
	
	@ApiOperation(notes = "保存广告推送", value = "保存广告推送")
	@PostMapping("/saveAdvertisingPush")
	public AjaxJson saveOrUpdate(String pushSwitch, String pushConditions, String pushUrl, String pushImage, String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(advertisingPushServiceInterface.saveOrUpdate(pushSwitch, pushConditions, pushUrl, pushImage, cityId));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("服务器异常").setData(null);
		}
		return ajaxJson;

	}
	
	@ApiOperation(notes = "获取广告推送", value = "获取广告推送")
	@PostMapping("/getAdvertisingPuth")
	public AjaxJson getAdvertisingPuth(String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(advertisingPushServiceInterface.getAdvertisingPuth(cityId));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("服务器异常").setData(null);
		}
		return ajaxJson;
		
	}

}
